local sk_le__tiandu = fk.CreateSkill {

  name = "sk_le__tiandu",

  tags = {},

}

Fk:loadTranslationTable {
  ["sk_le__tiandu"] = "天妒",
  [":sk_le__tiandu"] = "回合开始阶段，或当你的判定牌生效后，你可以随机摸一至三张牌。当任意角色获得至少三张牌后，你可以令其进行【闪电】判定。",
  ['$sk_le__tiandu1'] = "事已至此，顺应天命。",
  ['$sk_le__tiandu2'] = "得之我幸，失之我命。",
}

sk_le__tiandu:addEffect(fk.TurnStart, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(sk_le__tiandu.name)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:drawCards(math.random(1, 3), sk_le__tiandu.name)
  end,
})

sk_le__tiandu:addEffect(fk.FinishJudge, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(sk_le__tiandu.name)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:drawCards(math.random(1, 3), sk_le__tiandu.name)
  end,
})

sk_le__tiandu:addEffect(fk.AfterCardsMove, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(sk_le__tiandu.name) then
      for _, move in ipairs(data) do
        if move.to and (move.toArea == Card.PlayerHand or move.toArea == Card.PlayerEquip) then
          return #move.moveInfo >= 3
        end
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local target_p
    for _, move in ipairs(data) do
      if move.to and (move.toArea == Card.PlayerHand or move.toArea == Card.PlayerEquip) and #move.moveInfo >= 3 then
        target_p = move.to
      end
    end
    if target_p == nil then return end
    local pattern = ".|2~9|spade"
    local judge = {
      who = target_p,
      reason = "lightning",
      pattern = pattern,
    }
    room:judge(judge)
    if judge.card:matchPattern(pattern) then
      room:damage {
        to = target_p,
        damage = 3,
        damageType = fk.ThunderDamage,
        skillName = sk_le__tiandu.name,
      }
    end
  end,
})



return sk_le__tiandu
